package org.example.local;


import lombok.AllArgsConstructor;
import org.example.local.event.WeatherEvent;

import java.util.Random;


@AllArgsConstructor
//气象站 用于消息 不用于通知 只需要告诉电视台
public class WeatherStation {
    TVStation  tvStation;


    public String getInfo() {
        if(new Random().nextBoolean()){
            return "晴天";
        }
        return "阴天";
    }

    public void start() throws InterruptedException {
        while(true){
            //模拟产生信息 给事件总线发布
            String info = getInfo();
            WeatherEvent weatherEvent = new WeatherEvent(info);
            tvStation.publish(weatherEvent);


            Thread.sleep(1000);
        }
    }

}
